<?php

/**
 * 使用最小花费爬楼梯
 * Class Solution
 */
class Solution {

    /**
     * @param Integer[] $cost
     * @return Integer
     */
    function minCostClimbingStairs($cost) {
        if(sizeof($cost)<=2){
            return 0;
        }
        //
        $step1=$cost[0];
        unset($cost[0]);
        $c1=$step1+$this->minCostClimbingStairs($cost);
        $step2=$cost[0];
        if($step1<$step2){
            return $c1;
        }
        unset($cost[0]);
        $c2=$step2+$this->minCostClimbingStairs($cost);

        return $c2;
    }
}